﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Poco;
using Metier;

namespace WebApp
{
    public class ServerModelView
    {
        //
        // GET: /ServerModelView/

        public List<Table> Tables { get; set; }
        public List<Notification> Notifications { get; set; }
        public List<List<Notification>> list_notif_par_commande { get; set; }
        
        //public List<Notification> Notif { get; set; }




        public ServerModelView()
        {
            Tables = new List<Table>();
            Notifications = new List<Notification>();
            list_notif_par_commande = new List<List<Notification>>();
        }

        public List<Notification> getNotificationByType(List<Notification> list, string type)
        {
            List<Notification> mylist = new List<Notification>();
            if (list != null)
            {
                foreach (Notification item in list)
                {
                    Notification myplat = item;
                    if (item.getType().ToString().Equals(type))
                        mylist.Add(item);
                }
            }
            return mylist;
        }
        public void setNotificationByImportance()
        {
            foreach (var notifs_command in list_notif_par_commande)
            {                
                if (notifs_command != null)
                {
                    int nbplatspret = 0;
                
                    foreach (var type in Enum.GetValues(typeof(Poco.TypeNotification)))
                    {
                        List<Poco.Notification> NotificationByType = this.getNotificationByType(notifs_command, type.ToString());

                        foreach (var notif in NotificationByType)
                        {
                            if (notif.Type == "PlatPret") {
                                nbplatspret++;
                            }                      
                        }
                    }
                }
            }
        }

        public Plat getPlat(List<Plat> plat)
        {
            GestionPlat managerplat = new GestionPlat();
            return managerplat.Chercher(plat[0].Id);
        }

        public Table getTablebyTable(Commande command)
        {
            GestionTable table = new GestionTable();
            return table.Lister(command)[0];
        }

    }
}
